package com.hxy.langchain4jdeepseek.controller;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Controller {

    /**
     * deepseek官网
     * @param message
     * @return
     */
    @GetMapping("/chatmodel")
    public String modelChat(@RequestParam(value = "message", defaultValue = "Hello") String message) {
        ChatLanguageModel model = OpenAiChatModel.builder()
                .apiKey("sk-f800673c86cc483ca9fe6799b79d4dc5")
                .baseUrl("https://api.deepseek.com/v1")
                .modelName("deepseek-chat")
                .build();
        String result = model.chat(message);
        System.out.println("end - result = " + result);
        return result;
    }

    /**
     * siliconFlow官网
     */
    @GetMapping("/scModelChat/{message}")
    public String scModelChat(@PathVariable(value = "message" )String message){
        OpenAiChatModel model = OpenAiChatModel.builder()
                .apiKey("sk-muhzcoqmnaabxqbfmakialsvkrfohdngwetjwnnohgxvxdop")
                .baseUrl("https://api.siliconflow.cn/v1/")
                .modelName("deepseek-ai/DeepSeek-R1-Distill-Qwen-7B")
                .build();
        String result = model.chat(message);
        System.out.println("end - result =" +result);
        return result;
    }
}